<?php
/**
 * Created by b17
 * 2/22/12 7:16 PM
 */

namespace Managers\Decorators;

class NewsSearch implements Decorator
{
    protected $words;

    public function __construct($query)
    {
        $this->words = \G4T\Util\Words::getWords($query);
    }

    public function decorate(array $items)
    {
        foreach ($items as &$item) {
            $item['snippet'] = \G4T\Util\Snippet::getSnippet(strip_tags($item['content']), $this->words);
            $item['snippet'] = \G4T\Util\Highlighter::highlight($item['snippet'], $this->words);
            $item['title'] = \G4T\Util\Highlighter::highlight(strip_tags($item['title']), $this->words);
            $item['introduction'] = \G4T\Util\Highlighter::highlight(strip_tags($item['introduction']), $this->words);
        }
        return $items;
    }
}
